< Prev(J) / Next(K) > / View :

Filename: /text/sbasic/shared/03080601.xhp

(section: abs) (bookmark: bm_id3159201)
Abs function

Abs 関数

Abs Function [Runtime]
Abs 関数 [実行時](hd_id3159201.1)

Returns the absolute value of a numeric expression.
数値表式の絶対値を返します。(par_id3153394.2)

(/section: abs)

Syntax:
構文:(hd_id3149233.3)

Abs (Number)
Abs (Number)(par_id3147573.4)

Return value:
戻り値:(hd_id3156152.5)

Double
倍精度(par_id3149670.6)

Parameters:
パラメータ:(hd_id3154924.7)

Number: Any numeric expression that you want to return the absolute value for. Positive numbers, including 0, are returned unchanged, whereas negative numbers are converted to positive numbers.
Number: 絶対値を求める数値表式。ゼロを含めた正の値については、そのままの数値が返され、負の値については、正の値への変換値が返されます。(par_id3154347.8)

The following example uses the Abs function to calculate the difference between two values. It does not matter which value you enter first.
下記の例は、Abs 関数を用いて 2 つの数値の差を求めています。どちらの値を先に入力しても、同じ結果が得られます。(par_id3153381.9)

(embed text/sbasic/shared/00000003.xhp#errorcode : linkinfo)

Error Codes

エラーコード(hd_id3152869.37)

(/embed text/sbasic/shared/00000003.xhp#errorcode)

(embed text/sbasic/shared/00000003.xhp#err5 : linkinfo)

5 Invalid procedure call
5 無効なプロシージャー呼び出しです (par_id3150891.41)

(/embed text/sbasic/shared/00000003.xhp#err5)

Example:
例:(hd_id3148451.10)

Sub ExampleDifference
Sub ExampleDifference(par_id3154124.11)

Dim siW1 As Single
Dim siW1 As Single(par_id3150768.12)

Dim siW2 As Single
Dim siW2 As Single(par_id3125864.13)

siW1 = Int(InputBox$ ("Please enter the first amount","Value input"))
siW1 = Int(InputBox$ ("Please enter the first amount","Value input"))(par_id3145786.14)

siW2 = Int(InputBox$ ("Please enter the second amount","Value input"))
siW2 = Int(InputBox$ ("Please enter the second amount","Value input"))(par_id3149561.15)

Print "The difference is "; Abs(siW1 - siW2)
Print "The difference is "; Abs(siW1 - siW2)(par_id3145750.16)

End Sub
End Sub(par_id3147319.17)


< Prev / Next >